<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function sum(a, b) {
        return a + b;
    }

    //函数 参数的设置默认值
    function sum2(a, b = 100) {
        return a + b;
    }

    console.log(sum(100, 100)); //200
    console.log(sum(100)); //NaN

    console.log(sum2(100)); //200

    //箭头函数
    //1.去掉function
    //2.在括号后加箭头=>
    //3.代码只有一行，可以去掉{}
    //4.参数只有一个，可以去掉()
    let sum3 = (a, b) => a + b;
    console.log(sum(1,2));
    let sum4 = a => a + 1;
    let sum5 = (a, b) => {
        b = b + 1;
        return a + b
    }
</script>
</body>
</html>
